Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner: check null and empty for != any(subq) and = all(subq) #9106

Merged
merged 6 commits into from
Jan 21, 2019

Conversation

eurekaka
Copy link
Contributor

What problem does this PR solve?

Fix #8798

What is changed and how it works?

When converting "compare subquery" in expression rewriter, build additional 2 conditions to attach to projection:

  • check if subquery is empty; if subquery is empty, != any(subq) would always return false, while = all(subq) would always return true;
  • check if outer key is null when subquery is not empty; if outer key is null, both != any(subq) and = all(subq) would return null; note that it may be counterintuitive that null = all(1, 2) should return null, but it indeed holds and is verified on MySQL.

Check List

Tests

  • Unit test

Code changes

N/A

Side effects

  • Increased code complexity

Related changes

  • Need to cherry-pick to the release branch

@eurekaka eurekaka added type/bugfix This PR fixes a bug. sig/planner SIG: Planner labels Jan 17, 2019
@eurekaka
Copy link
Contributor Author

/run-all-tests

@codecov-io
Copy link

codecov-io commented Jan 17, 2019

Codecov Report

Merging #9106 into master will increase coverage by 0.1%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #9106     +/-   ##
=========================================
+ Coverage   67.16%   67.26%   +0.1%     
=========================================
  Files         372      372             
  Lines       77017    77067     +50     
=========================================
+ Hits        51729    51841    +112     
+ Misses      20660    20605     -55     
+ Partials     4628     4621      -7
Impacted Files Coverage Δ
planner/core/expression_rewriter.go 73.57% <100%> (+6.24%) ⬆️
executor/index_lookup_join.go 77.28% <0%> (-0.64%) ⬇️
planner/core/planbuilder.go 49.38% <0%> (-0.25%) ⬇️
store/tikv/2pc.go 79.63% <0%> (-0.1%) ⬇️
types/datum.go 68.76% <0%> (-0.02%) ⬇️
planner/core/task.go 96.56% <0%> (+0.62%) ⬆️
store/tikv/lock_resolver.go 42.65% <0%> (+0.94%) ⬆️
executor/join.go 79.42% <0%> (+1.56%) ⬆️
store/tikv/scan.go 77.31% <0%> (+3.36%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c371e66...2496e1c. Read the comment docs.

@eurekaka eurekaka requested review from zz-jason, winoros and alivxxx and removed request for zz-jason January 17, 2019 11:59
planner/core/expression_rewriter.go Outdated Show resolved Hide resolved
planner/core/expression_rewriter.go Outdated Show resolved Hide resolved
@eurekaka eurekaka requested a review from winoros January 18, 2019 12:05
Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zz-jason zz-jason added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 21, 2019
Copy link
Contributor

@alivxxx alivxxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alivxxx alivxxx added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 21, 2019
@alivxxx alivxxx merged commit 776c90f into pingcap:master Jan 21, 2019
@eurekaka eurekaka deleted the neany branch January 21, 2019 08:34
eurekaka added a commit to eurekaka/tidb that referenced this pull request Feb 21, 2019
eurekaka added a commit to eurekaka/tidb that referenced this pull request Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants